/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package se_juegos;

import Inference.OntologyAccess;
import java.util.List;
import javax.swing.DefaultListModel;
import javax.swing.JList;

/**
 *
 * @author FERNANDO MORENO
 */
public class EscogerConsolas extends javax.swing.JPanel {

    /**
     * Creates new form EscogerConsolas
     * @throws java.lang.Exception
     */
    public EscogerConsolas() throws Exception {
        List<String> consolas = OntologyAccess.getConsolas();
        initComponents();
        DefaultListModel model = new DefaultListModel();
        for (String consola : consolas) {
            model.addElement(consola);
        }
        this.lboxConsoles.setModel(model);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblChooseConsole = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        lboxConsoles = new javax.swing.JList();
        cmdConsole = new javax.swing.JButton();

        lblChooseConsole.setText("Escoge las consolas");

        lboxConsoles.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane1.setViewportView(lboxConsoles);

        cmdConsole.setText("Aceptar");
        cmdConsole.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                cmdConsoleMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(lblChooseConsole))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(56, 56, 56)
                        .addComponent(cmdConsole))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(lblChooseConsole)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cmdConsole)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void cmdConsoleMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cmdConsoleMouseClicked
        List<String> consoles = this.lboxConsoles.getSelectedValuesList();
        for(String console: consoles){
            SE_juegos.motor.ingresarConsola(console);
        }
        EscogerJuegos.dialog.setVisible(false);
    }//GEN-LAST:event_cmdConsoleMouseClicked


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cmdConsole;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblChooseConsole;
    private javax.swing.JList lboxConsoles;
    // End of variables declaration//GEN-END:variables
}
